#REGION functions
function Create-Folder([String] $foldername){
	if (Test-Path $foldername){
	} else {
	New-Item $foldername -ItemType directory | Out-Null
	}
}

#ENDREGION functions

Write-Host -ForegroundColor Yellow "Creating Folders & Shares for $env:computername."

Create-Folder C:\INETPUB
Create-Folder C:\INETPUB\VROOTS
Create-Folder C:\W3SVC
Create-Folder C:\W3SVC\LOGFILES
Create-Folder C:\ULSLOGS
Create-Folder C:\USAGEANALYSIS
Create-Folder C:\Builds
Create-Folder C:\SearchIndexes
Create-Folder C:\WorkbookCache
Create-Folder C:\Certs
Create-Folder C:\BlobCache
Create-Folder C:\BlobCache\14

$regpath = ".\reg\MaxConcurrentRequestsPerCPU.reg"
$reg = reg import "$regpath" 2>&1 # redirect to standard out
$reg[0].toString()

$net = NET SHARE W3SVC=C:\W3SVC\LOGFILES '/GRANT:ADMINISTRATORS,FULL' 2>&1
$net[0].toString()

# Share ULS Logs to all Users, no PII
$net = NET SHARE ULSLOGS=C:\ULSLOGS '/GRANT:ADMINISTRATORS,FULL' '/GRANT:EVERYONE,READ' 2>&1
$net[0].toString()

icacls "C:\ULSLOGS" /T /Q /grant Everyone:R | Out-Null


Write-Host -ForegroundColor Yellow "Creating Folders & Shares for $env:computername. COMPLETED" 
